<?php

namespace abstract_factory;

class DbAccess
{
    private $db = 'mysql';

    public function createUser()
    {
        $class_name = __NAMESPACE__ . '\\'  . ucfirst($this->db) . 'User';
        try {
            $reflect = new \ReflectionClass($class_name);
            return $reflect->newInstance();
        } catch (\ReflectionException $e) {
            return $e->getMessage();
        }
    }

    public function createDepartment()
    {
        $class_name = __NAMESPACE__ . '\\'  . ucfirst($this->db) . 'Department';
        try {
            $reflect = new \ReflectionClass($class_name);
            return $reflect->newInstance();
        } catch (\ReflectionException $e) {
            return $e->getMessage();
        }
    }
}